#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <assert.h>
#include <string.h>
#include "dominion/dominion.h"
#include "dominion/dominion_helpers.h"
#include "dominion/rngs.h"
#include "dominion/interface.h"

/* testing drawCard() function */
int drawCard(int player, struct gameState *state);

int main (int argc, char * argv[])
{
	/*modified from the initialization in the provided testUpdateCoins.c file */
    int seed = 1000;
    int numPlayer = 2;
    int k[10] = {adventurer, council_room, feast, gardens, mine
               , remodel, smithy, village, baron, great_hall};
	int r;
	
	/* test one -- to see if hand count is raised by one */
	struct gameState test_one;
    memset(&test_one, 23, sizeof(struct gameState));   // clear the game state
    r = initializeGame(numPlayer, k, seed, &test_one); // initialize a new game
	
	int handcount = test_one.handCount[0];
	drawCard(0, &test_one);
	
	if (test_one.handCount[0] == handcount + 1)
		printf("drawCard(): PASS when testing to see if hand count for player was incremented by one. \n");
	else
		printf("drawCard(): FAIL when testing to see if hand count for player was incremented by one. \n");
	
	/* test two -- to see if deck count is decremented by one */
	struct gameState test_two;
    memset(&test_two, 23, sizeof(struct gameState));   // clear the game state
    r = initializeGame(numPlayer, k, seed, &test_two); // initialize a new game
	
	int deckcount = test_two.deckCount[0];
	drawCard(0, &test_two);
	
	if (test_two.deckCount[0] == deckcount - 1)
		printf("drawCard(): PASS when testing to see if deck count for player was decremented by one. \n");
	else
		printf("drawCard(): FAIL when testing to see if deck count for player was decremented by one. \n");
	
	/* test three -- to see if an error is thrown when player's hand count is negative */
	struct gameState test_three;
    memset(&test_three, 23, sizeof(struct gameState));   // clear the game state
    r = initializeGame(numPlayer, k, seed, &test_three); // initialize a new game
	
	test_three.handCount[0] = -1;
	
	if (drawCard(0, &test_three) == -1) 
		printf("drawCard(): PASS when testing to see if an error is thrown for a negative hand count. \n");
	else
		printf("drawCard(): FAIL when testing to see if an error is thrown for a negative hand count. \n");
	
	/* test four -- to see if an error is thrown when player's deck count is negative */
	struct gameState test_four;
    memset(&test_four, 23, sizeof(struct gameState));   // clear the game state
    r = initializeGame(numPlayer, k, seed, &test_four); // initialize a new game
	
	test_four.deckCount[0] = -1;
	
	if (drawCard(0, &test_four) == -1) 
		printf("drawCard(): PASS when testing to see if an error is thrown for a negative deck count. \n");
	else
		printf("drawCard(): FAIL when testing to see if an error is thrown for a negative deck count. \n");
	
	return 0;
}